{% extends 'generic/object_detail.html' %}
{% load helpers %}
{% load render_table from django_tables2 %}

{% block extra_breadcrumbs %}
                {% if object.vrf %}
                    <li><a href="{% url 'ipam:vrf' pk=object.vrf.pk %}">{{ object.vrf }}</a></li>
                {% endif %}
{% endblock extra_breadcrumbs %}

{% block content_left_page %}
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>IP Address</strong>
            </div>
            <table class="table table-hover panel-body attr-table">
                <tr>
                    <td>Family</td>
                    <td>IPv{{ object.family }}</td>
                </tr>
                <tr>
                    <td>Status</td>
                    <td>
                        <span class="label" style="color: {{ object.status.color|fgcolor }}; background-color: #{{ object.status.color }}">{{ object.get_status_display }}</span>
                    </td>
                </tr>
                <tr>
                    <td>Role</td>
                    <td>
                        {% if object.role %}
                            <a href="{% url 'ipam:ipaddress_list' %}?role={{ object.role }}">{{ object.get_role_display }}</a>
                        {% else %}
                            <span class="text-muted">None</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>VRF</td>
                    <td>
                        {% if object.vrf %}
                            <a href="{% url 'ipam:vrf' pk=object.vrf.pk %}">{{ object.vrf }}</a>
                        {% else %}
                            <span>Global</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>DNS Name</td>
                    <td>{{ object.dns_name|placeholder }}</td>
                </tr>
                <tr>
                    <td>Description</td>
                    <td>{{ object.description|placeholder }}</td>
                </tr>
            </table>
        </div>
{% endblock content_left_page %}

{% block content_right_page %}
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Operational Details</strong>
            </div>
            <table class="table table-hover panel-body attr-table">
                <tr>
                    <td>Tenant</td>
                    <td>
                        {% if object.tenant %}
                            {% if object.tenant.group %}
                                <a href="{{ object.tenant.group.get_absolute_url }}">{{ object.tenant.group }}</a> /
                            {% endif %}
                            <a href="{{ object.tenant.get_absolute_url }}">{{ object.tenant }}</a>
                        {% else %}
                            <span class="text-muted">None</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>Assignment</td>
                    <td>
                        {% if object.assigned_object %}
                            <span><a href="{{ object.assigned_object.parent.get_absolute_url }}">{{ object.assigned_object.parent }}</a> ({{ object.assigned_object }})</span>
                        {% else %}
                            <span class="text-muted">&mdash;</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>NAT (inside)</td>
                    <td>
                        {% if object.nat_inside %}
                            <a href="{% url 'ipam:ipaddress' pk=object.nat_inside.pk %}">{{ object.nat_inside }}</a>
                            {% if object.nat_inside.assigned_object %}
                                (<a href="{{ object.nat_inside.assigned_object.parent.get_absolute_url }}">{{ object.nat_inside.assigned_object.parent }}</a>)
                            {% endif %}
                        {% else %}
                            <span class="text-muted">None</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>NAT (outside)</td>
                    <td>
                        {% if object.nat_outside %}
                            <a href="{% url 'ipam:ipaddress' pk=object.nat_outside.pk %}">{{ object.nat_outside }}</a>
                        {% else %}
                            <span class="text-muted">None</span>
                        {% endif %}
                    </td>
                </tr>
            </table>
        </div>
        {% include 'panel_table.html' with table=parent_prefixes_table heading='Parent Prefixes' %}
{% endblock content_right_page %}

{% block content_full_width_page %}
        {% if duplicate_ips_table.rows %}
            {# Custom version of panel_table.html #}
            <div class="panel panel-danger">
                <div class="panel-heading">
                    <strong>Duplicate IP Addresses</strong>
                    {% if more_duplicate_ips %}
                    <div class="pull-right">
                        <a type="button" class="btn btn-primary btn-xs"
                        {% if object.vrf %}
                        href="{% url 'ipam:ipaddress_list' %}?address={{ object.address.ip }}&vrf_id={{ object.vrf.pk }}"
                        {% else %}
                        href="{% url 'ipam:ipaddress_list' %}?address={{ object.address.ip }}&vrf_id=null"
                        {% endif %}
                        >Show all</a>
                    </div>
                    {% endif %}
                </div>
                {% render_table duplicate_ips_table 'inc/table.html' %}
            </div>
        {% endif %}
        {% include 'utilities/obj_table.html' with table=related_ips_table table_template='panel_table.html' heading='Related IP Addresses' panel_class='default noprint' %}
{% endblock content_full_width_page %}
